home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s1.arc / HANGUP.MOD < prev    next >
Text File  |  1987-08-31  |  4KB  |  87 lines

  1.  
  2. (*----------------------------------------------------------------------*)
  3. (*                   HangUpPhone  --- Hang up the phone                 *)
  4. (*----------------------------------------------------------------------*)
  5.  
  6. PROCEDURE HangUpPhone;
  7.  
  8. (*----------------------------------------------------------------------*)
  9. (*                                                                      *)
  10. (*     Procedure:  HangUpPhone                                          *)
  11. (*                                                                      *)
  12. (*     Purpose:    Hangs up the phone.                                  *)
  13. (*                                                                      *)
  14. (*     Calling Sequence:                                                *)
  15. (*                                                                      *)
  16. (*        HangUpPhone;                                                  *)
  17. (*                                                                      *)
  18. (*                                                                      *)
  19. (*     Calls:                                                           *)
  20. (*                                                                      *)
  21. (*        DELAY                                                         *)
  22. (*        Send_Modem_Command                                            *)
  23. (*        Async_Close                                                   *)
  24. (*        Async_Open                                                    *)
  25. (*        Async_Purge_Buffer                                            *)
  26. (*                                                                      *)
  27. (*     Remarks:                                                         *)
  28. (*                                                                      *)
  29. (*        First a hangup is tried by dropping DTR.  If that fails, and  *)
  30. (*        if a modem command delay string and a modem hang-up string    *)
  31. (*        are specified, they are used.                                 *)
  32. (*                                                                      *)
  33. (*----------------------------------------------------------------------*)
  34.  
  35. VAR
  36.    Open_Flag    : BOOLEAN;
  37.    Save_XonXoff : BOOLEAN;
  38.  
  39. BEGIN (* HangUpPhone *)
  40.                                    (* Make sure to clear XOFF received  *)
  41.                                    (* flag.                             *)
  42.  
  43.    Save_XonXoff     := Async_Do_XonXoff;
  44.    Async_Do_XonXoff := FALSE;
  45.  
  46.    IF ( Async_XOff_Received ) THEN
  47.       BEGIN
  48.          Async_XOff_Received := FALSE;
  49.          IF Do_Status_Line THEN
  50.             Write_To_Status_Line( '             ', 65 );
  51.       END;
  52.                                    (* Try hanging up by dropping DTR.   *)
  53.                                    (* We do this by closing port with   *)
  54.                                    (* DTR drop request.                 *)
  55.    Async_Close( TRUE );
  56.                                    (* Wait a second for DTR drop.       *)
  57.    DELAY( One_Second_Delay );
  58.                                    (* Re-open the port.                 *)
  59.  
  60.    Open_Flag := Async_Open( Comm_Port, Baud_Rate, Parity, Data_Bits,
  61.                             Stop_Bits );
  62.  
  63.                                    (* If modem hang-up command given,     *)
  64.                                    (* use it if dropping DTR didn't work. *)
  65.    IF Async_Carrier_Detect THEN
  66.       IF ( Modem_Hang_Up[0] <> #0 ) THEN
  67.          BEGIN
  68.  
  69.             DELAY( Modem_Escape_Time );
  70.  
  71.             Send_Modem_Command( Modem_Escape );
  72.  
  73.             DELAY( Modem_Escape_Time );
  74.  
  75.             Send_Modem_Command( Modem_Hang_Up );
  76.  
  77.             DELAY( Modem_Escape_Time );
  78.  
  79.          END;
  80.                                    (* Swallow any garbage characters *)
  81.    Async_Purge_Buffer;
  82.                                    (* Restore previous Xon/Xoff status *)
  83.  
  84.    Async_Do_XonXoff := Save_XonXoff;
  85.  
  86. END   (* HangUpPhone *);
  87.